<?php
    include '../connectDatabase.php';

    session_start();
    $ID = $_GET['code'];

    $usertype = $_SESSION['type'];

    $sql = "select * from users where user_id='$ID'";

    $result = mysqli_query($conn,$sql);
    $records = array();
    while($record = mysqli_fetch_array($result))
    {
        $records [] = $record;
    }
    foreach($records as $row){
        $type = $row['user_type'];
    }



    if($usertype != "超级管理员" && ($type == "管理员" || $type == "超级管理员")){
        //echo $usertype;
        echo "<script>alert('您的权限不足！');history.go(-1);</script>" ;
    }   else{

        $sqlstr1 = "delete from users where user_id = '$ID'";        //定义删除语句
        $result = mysqli_query($conn,$sqlstr1);                //执行删除操作
        if($result){
            echo "<script>alert('删除成功');window.location.href='../Page/look_user.php';</script>";
        }else{
            echo "<script>alert('删除失败');history.go(-1);</script>";
        }
    }
?>